package com.briup.srms.base.service.impl;

import com.jacky.base.utils.PageVM;
import com.briup.srms.base.bean.BaseFile;
import com.briup.srms.base.bean.BaseFileExample;
import com.briup.srms.base.dao.BaseFileMapper;
import com.briup.srms.base.dao.extend.BaseFileExtendMapper;
import com.briup.srms.base.service.IBaseFileService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BaseFileServiceImpl implements IBaseFileService {

    @Autowired
    private BaseFileMapper baseFileMapper;
    @Autowired
    private BaseFileExtendMapper baseFileExtendMapper;
    
    @Override
    public void save(BaseFile baseFile) throws Exception {
    	System.out.println("上传："+baseFile.getFileName());
        baseFileMapper.insert(baseFile);
    }

    @Override
    public void deleteById(String id) throws Exception {
        baseFileMapper.deleteByPrimaryKey(id);
    }

	@Override
	public List<BaseFile> findAll() {
		return baseFileMapper.selectByExample(new BaseFileExample());
	}
	
	@Override
	public PageVM<BaseFile> pageQuery(int page, int pageSize, String fileName,Long datasetId,String uploadDate) {
		List<BaseFile> list = baseFileExtendMapper.query(page, pageSize, fileName,datasetId,uploadDate);
		long total = baseFileExtendMapper.count(fileName,datasetId,uploadDate);
		PageVM<BaseFile> pageVM = new PageVM<>(page, pageSize, total, list);
		return pageVM;
	}
}
